package com.dinggao.bangda.interaction;

import android.app.DatePickerDialog;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.icu.util.Calendar;
import android.os.Build;
import android.os.Bundle;
import android.provider.CalendarContract;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.dinggao.bangda.R;

/**
 * Created by Administrator on 2017/4/13.
 */

public class PassengerFragment extends Fragment implements View.OnClickListener {
    private View view;
    private FragmentTransaction fragmentTransaction;
    private BeanFragment beanFragment;
    private GoodsFragment goodsFragment;
    private Button car;
    private Button goods;
    private LinearLayout linearLayout;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (view == null) {
            view = inflater.inflate(R.layout.passenger_home, null);
            return view;
        }
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
        fragmentTransaction = getChildFragmentManager().beginTransaction();
        beanFragment = new BeanFragment();
        fragmentTransaction.add(R.id.frame_passenger_home,beanFragment).commit();
//        fragmentTransaction.add(R.id.frame_passenger_home,goodsFragment).commit();
    }
    public void initView(){
//        Drawable left1 = Drawable.createFromPath();

        beanFragment = new BeanFragment();
        goodsFragment = new GoodsFragment();
        linearLayout = (LinearLayout) view.findViewById(R.id.background1);
        car = (Button) view.findViewById(R.id.car1_passenger_btn);
        goods = (Button) view.findViewById(R.id.goods1_passenger_btn);
        car.setOnClickListener(this);
        goods.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.car1_passenger_btn:
                linearLayout.setBackgroundDrawable(getResources().getDrawable(R.drawable.leftweirt));
                car.setTextColor(getResources().getColor(R.color.menu_click));
                goods.setTextColor(getResources().getColor(R.color.menu_text));
                fragmentTransaction = getChildFragmentManager().beginTransaction();
                fragmentTransaction.replace(R.id.frame_passenger_home,beanFragment).commit();
                break;
            case R.id.goods1_passenger_btn:
                linearLayout.setBackgroundDrawable(getResources().getDrawable(R.drawable.leftblank));
                car.setTextColor(getResources().getColor(R.color.menu_text));
                goods.setTextColor(getResources().getColor(R.color.menu_click));
                fragmentTransaction = getChildFragmentManager().beginTransaction();
                fragmentTransaction.replace(R.id.frame_passenger_home,goodsFragment).commit();
                break;
            default:
                break;
        }
    }
}
